package huichun_m

import (
	"frozen-go-mini/common/domain"
	"frozen-go-mini/common/resource/mysql"
)

// HuichunNoticeBar  公告栏
type HuichunNoticeBar struct {
	mysql.Entity
	Name      string   `gorm:"column:name"`       //  公告id
	ProductId mysql.ID `gorm:"column:product_id"` //  绑定的商品id
	Sort      int64    `gorm:"column:sort"`       //  排序
	Status    int64    `gorm:"column:status"`     //  上下架 1:上架 0:下架
}

func (HuichunNoticeBar) TableName() string {
	return "huichun_notice_bar"
}
func GetNoticeBar(model *domain.Model) []HuichunNoticeBar {
	var res []HuichunNoticeBar
	if err := model.DB().Model(HuichunNoticeBar{}).Where("status = 1").Order("sort desc").Find(&res).Error; err != nil {
		model.Log.Errorf("GetNoticeBar fail:%v", err)
	}
	return res
}
